<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="strutsTags"%>
<%@taglib prefix="ty" uri="/wyzzTags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<head>
	<base href="<%=basePath%>">
	<title>员工社保补缴</title>
	<link href="resource/css/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="dwr/interface/SearchEbpAction.js"></script>
	<script type="text/javascript" src="resource/js/hrm/compensation.js"></script>
</head>
<body onload="HRMCommon.check_order();">
	<s:component template="bodyhead">
		<s:param name="pagetitle" value="'员工社保补缴('+yearMonth+')'" />
	</s:component>
	<span class="errorMessage" id="errMsg"></span>
	<s:form action="searchEbp" id="searchEbpForm" name="searchEbpForm"
		namespace="/compensation" method="post">
		<s:hidden id="ebpId" name="ebpId" />
		<s:hidden id="actionErrorS" name="actionErrorS"></s:hidden>
		<table width="100%" class="formtable">
			<tr>
				<td>
					<s:hidden id="id" name="detailid" />
					<s:hidden id="order" name="page.order" />
					<s:hidden id="page.currentPage" name="page.currentPage" />
					<input type="hidden" id="operate" name="page.operate" />
					<table width="100%">
						<tr>
							<s:textfield label="员工" id="empAdv" name="emp.empName" size="15"
								maxlength="64" />
							<td align="right">
								组织单元:
							</td>
							<td>
								<s:orgselector id="orgselector1"
									name="emp.empDeptNo.departmentName"
									hiddenFieldName="emp.empDeptNo.id" isShowDisable="show" />
							</td>
							<s:select label="工作地区" id="empLocationNo"
								name="emp.empLocationNo.id" list="locationList" listKey="id"
								listValue="locationName" multiple="false" headerKey=""
								headerValue="请选择" />
							<s:select label="社保种类" id="empBenefitTypeAdv"
								name="emp.empBenefitType.id" list="ebfTypeList" listKey="id"
								listValue="benefitTypeName" multiple="false" headerKey=""
								headerValue="请选择" />
						</tr>
					</table>
				</td>
				<td align="center">
					<input title="[Alt+F]" accesskey="F" id="submit_button"
						class="button" type="button" onclick="submitForm();" value="查询">
					<input title="[Alt+C]" accesskey="C" class="button" type="button"
						value="重置" onClick="window.location='searchEbp.action';">
				</td>
			</tr>
		</table>

		<!-- 操作 -->
		<div class="operatediv">
			<span class="operatedivleft"> <input class="button"
					type="button" id="down" name="down" value="前一月"
					onclick="HRMCommon.changeMonth(-1,'searchEbpForm');"> <s:textfield
					id="yearMonth" name="yearMonth" size="7" maxlength="7"
					onclick="WdatePicker({dateFmt:'yyyy-MM', el:'yearMonth'})"
					onchange="HRMCommon.checkYMAndSubmit(this,'searchEbpForm')" /> <input
					class="button" type="button" id="up" name="up" value="后一月"
					onclick="HRMCommon.changeMonth(1,'searchEbpForm');"> <s:if
					test="canEdit=='true'">
					<input class="button" type="button" id="showAdd" name="showAdd"
						value="新增" onclick="showAddDiv();" />
					<input class="button" type="button" id="batchDelete"
						name="batchDelete" value="批量删除" onclick="batchDeleteEbp();" />
				</s:if> <s:else>
					<input class="button" type="button" id="showAdd" name="showAdd"
						value="新增" onclick="showAddDiv();" disabled="disabled" />
					<input class="button" type="button" id="batchDelete"
						name="batchDelete" value="批量删除" onclick="batchDeleteEbp();"
						disabled="disabled" />
				</s:else> </span>
			<span class="operatedivright">本次查询共得到<s:property
					value="page.totalRows" />条补缴记录</span>
		</div>

		<table id="empbenefittable" cellpadding="0" cellspacing="0"
			width="100%" border="0" class="gridtableList">
			<tr>
				<th>
					<input type="checkbox" id="changIds" name='changIds'
						class="checkbox"
						onclick="HRMCommon.checkAllByName('changIds','changIds');" />
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('emp.empDistinctNo','searchEbpForm');">员工编号</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='emp.empDistinctNo_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('emp.empName','searchEbpForm');">姓名</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='emp.empName_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpBelongYearmonth','searchEbpForm');">补缴年月</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpBelongYearmonth_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('beneType.benefitTypeName','searchEbpForm');">社保种类</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='beneType.benefitTypeName_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpPensionAmountb','searchEbpForm');">社保基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpPensionAmountb_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpHousingAmountb','searchEbpForm');">公积金基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpHousingAmountb_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpInsuranceAmountb','searchEbpForm');">其他基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpInsuranceAmountb_img'>
				</th>
				<th>
					个人缴社保
				</th>
				<th>
					公司缴社保
				</th>
				<th>
					备注
				</th>
				<th>
					操作
				</th>
			</tr>
			<s:if test="!ebpList.isEmpty()">
				<s:iterator value="ebpList">
					<input type="hidden"
						id="ebpBelongYearmonth<s:property value='ebpId'/>"
						name="ebpBelongYearmonth<s:property value='ebpId'/>"
						value="<s:property value='ebpBelongYearmonth' />" />
					<input type="hidden" id="ebpComments<s:property value='ebpId'/>"
						name="ebpComments<s:property value='ebpId'/>"
						value="<s:property value='ebpComments' />" />
					<tr id="<s:property value='ebpId'/>">
						<td align="center">
							<input type="checkbox" id="changIds" name='changIds'
								class="checkbox" value="<s:property value='ebpId'/>" />
						</td>
						<td id="ebpEmpno.empDistinctNo<s:property value='ebpId'/>"
							nowrap="nowrap" align="center">
							<span
								title="在职状态：<s:property value='getEmpStatusName(ebpEmpno.empStatus)'/>
所属地区：<s:property value='ebpEmpno.empLocationNo.locationName'/>
所属部门：<s:property value='ebpEmpno.empDeptNo.departmentName'/>
<s:if test="ebpEmpno.empIdentificationType==0">身份证号：<s:property value='ebpEmpno.empIdentificationNo'/></s:if>" />
								<s:property value="ebpEmpno.empDistinctNo" />
						</td>
						<td id="ebpEmpno.empName<s:property value='ebpId'/>"
							align="center">
							<s:property value="ebpEmpno.empName" />
						</td>
						<td id="ebpBelongYearmonth<s:property value='ebpId'/>"
							nowrap="nowrap" align="center">
							<s:property value="ebpBelongYearmonth" />
						</td>
						<td id="ebpEmpno.empBenefitType<s:property value='ebpId'/>"
							align="center">
							<s:property value="ebpEmpno.empBenefitType.benefitTypeName" />
						</td>
						<td id="ebpPensionAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpPensionAmountb" />
						</td>
						<td id="ebpHousingAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpHousingAmountb" />
						</td>
						<td id="ebpInsuranceAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpInsuranceAmountb" />
						</td>
						<td id="showColumn15<s:property value='ebpId'/>" nowrap="nowrap"
							align="right">
							<s:property value="showColumn15" />
						</td>
						<td id="showColumn16<s:property value='ebpId'/>" nowrap="nowrap"
							align="right">
							<s:property value="showColumn16" />
						</td>
						<td align="center">
							<s:property value="ebpComments" />
						</td>
						<td align="center">
							<s:if test="canEdit=='true'">
								<img
									onclick="getEbpById(this, '<s:property value="ebpId" />', '<s:property value="ebpEmpno.empName" />', '<s:property value="ebpBelongYearmonth" />');"
									alt="修改" title="修改" style="cursor: pointer;"
									src="resource/images/edit.gif"></img>
								<img
									onclick="deleteOneEbp('<s:property value='ebpId'/>', '<s:property value="ebpBelongYearmonth" />');"
									alt="删除" title="删除" style="cursor: pointer;"
									src="resource/images/delete.gif"></img>
							</s:if>
						</td>
					</tr>
				</s:iterator>
			</s:if>
			<s:else>
				<tr>
					<!-- 不存在符合条件的员工社保资料！ -->
					<td align="center" colspan="12">
						不存在符合条件的员工社保资料！
					</td>
				</tr>
			</s:else>
		</table>
		<s:pager end="page.end" pageNo="page.currentPage"
			totalRows="page.totalRows" totalPages="page.totalPages"
			formId="searchEbpForm" start="page.start" />

		<div id="dlgAddEmpBenefit"
			title="社保补缴(缴费年月<s:property value="yearMonth"/>)"
			class="prompt_div_inline" style="width: 520;">
			<s:form id="addBenefitForm" method="post">
				<table width="100%" class="prompt_div_body">
					<tr>
						<td align="left" colspan="3">
							<input type="hidden" id="empId" name="empId" />
							<label class="label" for="empName">
								员工:
							</label>
							<input type="text" readonly="true" id="empName" name="empName"
								value="<s:property value='empName'/>" />
							<img onclick="selectEmp();" id="search_emp" alt='点击图标选择员工'
								title="点击图标选择员工" class="urlimg"
								src="resource/images/search_icon.gif" />
						</td>
						<td align="left" colspan="2">
							缺省基数:
							<s:select id="defaultType" name="defaultType"
								list="#{0:'当前月', 1:'补缴月'}" multiple="false" emptyOption="false"
								onchange="changeDefaultType(this.value);" />
						</td>
					</tr>
					<tr>
						<td align="center">
							补缴年月
						</td>
						<td align="center">
							社保基数
						</td>
						<td align="center">
							公积金基数
						</td>
						<td align="center">
							其他基数
						</td>
						<td align="center">
							备注
						</td>
					</tr>
					<%
						for (int i = 1; i <= 6; i++) {
					%>
					<tr>
						<td>
							<input type="text" id="addyearmonth<%=i%>"
								name="addyearmonth<%=i%>"
								onblur="getDefaultData(<%=i%>, this.value);"
								onchange="getDefaultData(<%=i%>, this.value);"
								onclick="WdatePicker({dateFmt:'yyyyMM', el:'addyearmonth<%=i%>'})"
								value="" size="7" maxlength="6" />
						</td>
						<td>
							<input id="ebpPensionAmount<%=i%>" name="ebpPensionAmount<%=i%>"
								onkeypress="HRMCommon.checkOnKeyDownFloat(event,this)"
								onblur="HRMCommon.checkFloatAndFormat(this);" value="" size="9"
								maxlength="12" />
						</td>
						<td>
							<input id="ebpHousingAmount<%=i%>" name="ebpHousingAmount<%=i%>"
								onkeypress="HRMCommon.checkOnKeyDownFloat(event,this)"
								onblur="HRMCommon.checkFloatAndFormat(this);" value="" size="9"
								maxlength="12" />
						</td>
						<td>
							<input id="ebpInsuranceAmount<%=i%>"
								name="ebpInsuranceAmount<%=i%>"
								onkeypress="HRMCommon.checkOnKeyDownFloat(event,this)"
								onblur="HRMCommon.checkFloatAndFormat(this);" value="" size="9"
								maxlength="12" />
						</td>
						<td>
							<input id="memo<%=i%>" name="memo<%=i%>" size="25"
								maxlength="128" value="" />
						</td>
					</tr>
					<%
						}
					%>
					<tr>
						<td colspan="5">
							<font style="color: red"> *注1：所属年月格式"200908"表示"2009年8月"。<br />
								*注2：多个员工不填基数，系统自动匹配当前月或补缴月基数。 </font>
						</td>
					</tr>
					<tr>
						<td colspan="5" class="prompt_div_bottom">
							<input id="ebpAddbtn" class="button" type="button" value="确定"
								onclick="submitAddEbp();" />
							<input class="button" type="button" value="取消"
								onclick="HRMCommon.closeDialog('dlgAddEmpBenefit');" />
						</td>
					</tr>
				</table>
			</s:form>
		</div>
	</s:form>

	<!-- modify empbenefit -->
	<div id="dlgModifyEmpBenefit" class="prompt_div_inline"
		style="width: 460;">
		<div id="hiddenColumns" style="display: none"></div>
		<input type="hidden" id="ebpId_modify" name="ebpId_modify" />
		<input type="hidden" id="modiaddyearmonth" name="modiaddyearmonth" />
		<table id="beneItems" width="100%" class="prompt_div_body">
			<tr>
				<td>
					备注:
				</td>
				<td colspan="3">
					<s:textarea id="modibeneComments" cols="34" rows="4"
						onkeyup="if(this.value.length>255){this.value=this.value.substring(0, 255)}" />
				</td>
			</tr>
			<tr>
				<td colspan="4" class="prompt_div_bottom">
					<input id="ebfAddbtn" class="button" type="button" value="确定"
						onClick="modifyEbpSubmit();" />
					<input class="button" type="button" value="取消"
						onclick="HRMCommon.closeDialog('dlgModifyEmpBenefit');" />
				</td>
			</tr>
		</table>
		<iframe scrolling="no"
			style="position: absolute; z-index: -1; height: 1px; width: 389px; top: 0px; left: 0px;"
			frameborder="0"></iframe>
	</div>

	<div id="dlgSelectEmp" title="员工选择" class="prompt_div_inline">
		<div id="mulSelect">
			<!--  //typeAndStatus中前一个数值如果==1，选出社保种类不为空的员工，第二个数如果==0，选出在职员工 -->
			<input type="hidden" id="typeAndStatus" value="1;0" />
			<s:empselector id="empselector" name="emp.empDeptNo.departmentName"
				condition="hasBeneType&typeAndStatus"
				hiddenFieldName="emp.empDeptNo.id" />
		</div>
		<div class="prompt_div_bottom" style="valign: middle">
			<input class="button" type="button" id="empAdd" onclick="empAdd();"
				value="确定" />
			<input class="button" type="button"
				onclick="HRMCommon.closeDialog('dlgSelectEmp');" value="取消" />
		</div>
	</div>

	<script type="text/javascript">

// 鼠标离开填写月份的文本框后将默认基数值显示在相应文本框中；
function getDefaultData(index, yearMonthi){
    if(yearMonthi.trim() == "") return;

    var empId = document.getElementById("empId").value;
	if (empId.indexOf(",") != -1) return;
	
    var yearMonth = document.getElementById("yearMonth").value;
    yearMonth = yearMonth.substring(0,4) + "" + yearMonth.substring(5,7);
    if(!checkDate2(yearMonthi)){
        return;
    }
    var defaultType = document.getElementById("defaultType").value;
    var selectMonth;
    if(defaultType == 0){
	    // 判断日期格式是否正确
	    if (HRMCommon.checkY_M(document.getElementById("yearMonth")) == null) return;
        selectMonth = yearMonth;
    }else if(defaultType == 1){
    	 // 判断日期格式是否正确
	    if (HRMCommon.checkYM(document.getElementById("addyearmonth"+index)) == null) return;
        selectMonth = yearMonthi;
    }

    // 获取某个员工某个月的社保基数值
    SearchEbpAction.getEbpByEmpMonth(empId, selectMonth, getDefaultCallback);
    function getDefaultCallback(result){
        if (result.error != null && result.error != "") {
            alert(result.error);
            return;
        }
        var data = result.param_succ;
        document.getElementById("ebpPensionAmount"+index).value = data!=null&&data.ebpPensionAmountb!=null?data.ebpPensionAmountb:"";
        document.getElementById("ebpHousingAmount"+index).value = data!=null&&data.ebpHousingAmountb!=null?data.ebpHousingAmountb:"";
        document.getElementById("ebpInsuranceAmount"+index).value = data!=null&&data.ebpInsuranceAmountb!=null?data.ebpInsuranceAmountb:"";
    }
}

// 默认类型改变，相应基数值改变；
function changeDefaultType(type){
    var yearMonth = document.getElementById("yearMonth").value;
    yearMonth = yearMonth.substring(0,4) + "" + yearMonth.substring(5,7);

    for(var i=1; i<=6; i++){
        var yearMonthi = document.getElementById("addyearmonth" + i).value;
        if(!checkDate2(yearMonthi)){
	        return;
	    }
	    if(yearMonthi!=null && yearMonthi.trim()!=""){// 月份不为空；
	        if(type == 0){// 当前月；
	        	yearMonthi = yearMonth;
	    	}
	        getDefaultData(i, yearMonthi);
	    }
    }
}



function submitForm(){
    var yearMonth = document.getElementById("yearMonth").value;
    if(!checkDate1(yearMonth)){
        return;
    }
    document.forms[0].submit();
}

// 显示社保补缴页面；
function showAddDiv(){
    HRMCommon.openDialog("dlgAddEmpBenefit","searchEbpForm");
    document.getElementById("empName").value = "" ;
    document.getElementById("empId").value = "";
    for(var i=1; i<=6; i++){
        document.getElementById("addyearmonth" + i).value = "" ;
	    document.getElementById("ebpPensionAmount" + i).value = "" ;
	    document.getElementById("ebpHousingAmount" + i).value = "" ;
	    document.getElementById("ebpInsuranceAmount" + i).value = "" ;
	    document.getElementById("memo" + i).value = "" ;
    }
}

// 添加提交；
function submitAddEbp(){
    var empId = document.getElementById("empId").value;
    var addyearMonth = '';
    if(empId==null || empId==''){
        alert("请选择员工！");
        return;
    }
    
    var AddEbpBean = function(){};
    var ebpBean = new AddEbpBean();
    var num = 0;
    for(var i=1; i<=6; i++){
        var addyearmonth = document.getElementById("addyearmonth"+i).value.trim();
	    var ebpPensionAmount = document.getElementById("ebpPensionAmount"+i).value.trim();
	    var ebpHousingAmount = document.getElementById("ebpHousingAmount"+i).value.trim();
	    var ebpInsuranceAmount = document.getElementById("ebpInsuranceAmount"+i).value.trim();
	    var memo = document.getElementById("memo"+i).value.trim();
	    var obj=null;
	    if(addyearmonth != ""){
		    // 判断补缴年月日期格式是否正确
	    	if(HRMCommon.checkYM(document.getElementById("addyearmonth"+i)) == null) return;
			if(!HRMCommon.checkFloat(ebpPensionAmount) || !HRMCommon.checkFloat(ebpHousingAmount) || !HRMCommon.checkFloat(ebpInsuranceAmount)){
				alert("输入的数字格式错误，正确格式为：8.88或-8.88或.88或-.88");
				return;
			}
			num++;
	    }
	    // 当一个员工补缴时，必须判断数据必须填写
	    if (empId.indexOf(",") == -1 && addyearmonth!='' && ebpPensionAmount=='' && ebpHousingAmount=='' && ebpInsuranceAmount=='') {
	    	alert("请将数据填写完整后再保存！");
	        return ;
	    }
	    // 组装数据
	    if(addyearmonth!=''){
	    	eval("ebpBean.addyearmonth"+i+"=addyearmonth");
	    	eval("ebpBean.ebpPensionAmount"+i+"=ebpPensionAmount");
	    	eval("ebpBean.ebpHousingAmount"+i+"=ebpHousingAmount");
	    	eval("ebpBean.ebpInsuranceAmount"+i+"=ebpInsuranceAmount");
	    	eval("ebpBean.memo"+i+"=memo");
	    }
    }
    // 补缴月份都为空时报错
    if (num == 0) {
    	alert("请将数据填写完整后再保存！");
        return ;
    }
    var yearMonth = document.getElementById("yearMonth").value;
    ebpBean.yearMonth = yearMonth;
    ebpBean.empId = empId;
	
 	// 社保补缴回调函数；
 	SearchEbpAction.saveBeneAddData(ebpBean, addCallback);

 	function addCallback(msg) {
		try{
			var retcode = HRMCommon.comboMsgHandler(msg);
			if(retcode == 'SUCC') {
				HRMCommon.closeDialog("dlgAddEmpBenefit");
		 	 	document.getElementById("actionErrorS").value = msg;
				document.forms[0].submit();
			}
		}catch(e){alert(e);}
 	}
}

// 删除一条补缴记录；
function deleteOneEbp(ebpId, byearMonth){
    if(!confirm("您确定要删除该记录吗？")){
        return;
    }
    document.getElementById("ebpId").value = ebpId;
    document.forms[0].action = "compensation/deleteOneEbp.action";
    document.forms[0].submit();
}

// 删除多条记录
function batchDeleteEbp() {
	var checkBoxName = document.getElementsByName('changIds');
	var ebpIds = "";
	var num = 0;
	for(var i=1;i<checkBoxName.length;i=i+1){
		if(checkBoxName[i].checked===true){
			var value = checkBoxName[i].value.split("_");
			if(ebpIds != "") ebpIds += ",";
			ebpIds += value[0];
			num++;
		}
	}
	if (ebpIds.trim().length == 0) {
		alert("请至少选择一条补缴记录！");
		return;
	}

	if(!confirm("您确定要删除这"+num+"条记录吗？")){
        return;
    }
	
	document.getElementById("ebpId").value = ebpIds;
    document.forms[0].action = "compensation/deleteOneEbp.action";
    document.forms[0].submit();
}

// 显示修改页面；
var trObj;
var insertRowCount = 0;
function getEbpById(obj, ebpId, empName, byearMonth){
     trObj = obj.parentNode.parentNode;
     document.getElementById("ebpId_modify").value = ebpId;
     document.getElementById("modiaddyearmonth").value = byearMonth;
     
    //document.getElementById("div_modify").innerHTML = empName;
     $('#dlgModifyEmpBenefit').dialog("option","title","修改"+empName+"的社保补缴记录(所属年月:"+byearMonth+")");
     SearchEbpAction.getEbpItemsById(ebpId, getByIdCallback);
     function getByIdCallback(data){
         if(data == null){
             alert("没有权限，或数据出错！");
         }
         //在beneItems表中显示社保项目，并且全能修改；
         document.getElementById("hiddenColumns").innerHTML = ""; //清空保存隐藏域值得div；
         for(var i=0; i<insertRowCount; i++){// 删除社保项目行；
             if (i%2 != 0) continue;
             document.getElementById('beneItems' + i).parentNode.removeChild(document.getElementById('beneItems' + i));
         }
         var hiddenColumns = "";
         var trObj = null;
         var tdObj = null;
         insertRowCount = 0;
         var itemObj = null;
         for(var i=0; i<data.length; i++){
             itemObj = data[i];
             if(itemObj.esaiEsdd.esddDataType<10 || itemObj.esaiEsdd.esddDataType>16){// 非社保项目值；
                 hiddenColumns += "<input type='hidden' name='ebpColumn' id='ebpColumn"+ itemObj.esaiDataSeq + "' value='"+ (itemObj.itemValue==null?0.00:itemObj.itemValue) +"'/>";
                 continue;
             }
             if (insertRowCount%2 == 0) {
	             // 是社保项目值，插入一行，显示并修改；
	             trObj = document.getElementById('beneItems').insertRow(insertRowCount/2);
	             trObj.id = 'beneItems'+insertRowCount;
             }
             
             var toWrite="onkeypress='HRMCommon.checkOnKeyDownFloat(event,this)' onblur='HRMCommon.checkFloatAndFormat(this);' ";
             tdObj = document.createElement('td');
			 tdObj.height='27px';
			 tdObj.nowrap='true';
			 tdObj.innerHTML=itemObj.esaiEsdd.esddName + ":";
			 trObj.appendChild(tdObj);
			 tdObj = document.createElement('td');
			 tdObj.align='left';
			 tdObj.height='27px';
			 tdObj.innerHTML="<input type='text' "+toWrite+" name='ebpColumn' id='ebpColumn"+ itemObj.esaiDataSeq + "' " + "value='" + itemObj.itemValue.toFixed(2) + "'" + " size='12' maxlength='12' style='text-align:right'/>";
			 trObj.appendChild(tdObj);

			 insertRowCount++;
         }
         
         // 设置不需要修改的值；
         document.getElementById("hiddenColumns").innerHTML = hiddenColumns; 
         // 显示年月，备注；
         var commentsId = "ebpComments"+ebpId;
         document.getElementById("modibeneComments").value = document.getElementById(commentsId).value;
         HRMCommon.openDialog("dlgModifyEmpBenefit");
     }
}

// 提交修改；
function modifyEbpSubmit(){
    var ebpId = document.getElementById("ebpId_modify").value; // 要修改的社保补缴数据的id；
    //找到薪资发放弹出层的所有输入框
	var eles = document.getElementsByName("ebpColumn");
	var columns = "";
	for(var i = 1 ;i<=eles.length;i++){
	    var obj = document.getElementById("ebpColumn" + i);
	    if (!HRMCommon.checkFloat(obj.value)){
	    	alert("输入的数字格式错误，正确格式为：8.88或-8.88或.88或-.88");
			return;
	    }
		if(obj.value!=""){
			columns += obj.value + ",";
		}else{
			columns += "0.00" + ",";
		}
	}

    var modiComments = document.getElementById("modibeneComments").value;
    SearchEbpAction.modifyEbp(ebpId, columns, modiComments, modifyCallback);
    function modifyCallback(info){
        // 判断权限
        if(info==null){
             alert("您没有权限执行此操作！");
             return;
        }
         
        // 修改页面td数据
        var tds = trObj.cells;
        tds[8].innerHTML = info.showColumn15;
        tds[9].innerHTML = info.showColumn16;
        tds[10].innerHTML = info.ebpComments;

        // 将备注放到隐藏域
        document.getElementById("ebpComments" + ebpId).value = modiComments;

        // 关窗口，并显示成功信息
        HRMCommon.closeDialog("dlgModifyEmpBenefit");
        var empName = tds[2].innerHTML; // 修改的员工姓名
        empName = empName.replace(/(^\s*)|(\s*$)/g, "");
        var byearMonth = document.getElementById("modiaddyearmonth").value; // 修改的社保补缴所属年月
        byearMonth = byearMonth.substring(0,4)+"年"+byearMonth.substring(4)+"月";
        successMsg("errMsg", "您已修改" + empName + "社保补缴(所属年月" + byearMonth +  ")，改动将在重新初始化薪资后生效。");
    }
}

// 检查'yyyy-MM'格式；
function checkDate1(date){
    if(date==null || date.trim()=='') return true;
    if(!HRMCommon.isDate(date)){
        alert("查询日期 "+date+" 输入不正确，格式应如：2009-08, 请重新输入!");
        return false;
    }
    return true;
}

// 检查'yyyyMM'格式；
function checkDate2(date){
	if(date==null || date.trim()=="") return;
    var regExp = /^(\d{4})(\d{2})$/;
    if(!regExp.test(date)){
        alert("补缴年月 "+date+" 输入不正确，格式应如：200908, 请重新输入!");
        return false;
    }
    return true;
}

//判断小数点及整数部分的长度
function changeDmalPoint(Decimal){
	if(!Decimal || Decimal.value.length == 0){
        return;
	}
 	var l = Decimal.value.length;
 	var flag=0;
 	if(Decimal.value.charAt(0)=="."){
 		Decimal.value='';
 		return;
 	}
 	for(var i=0; i<l; i++){
  		var digit = Decimal.value.charAt(i);
  		if(digit=="."){
  			if(flag>0){
  				Decimal.value=Decimal.value.substring(0,i);
  			}
  			flag++;
  		}
 	}
 	if(flag==0){
  			if(l>7){
  				Decimal.value=Decimal.value.substring(0,7);
  			}
  		} 
	return;
}

function selectEmp() {
	$('#dlgSelectEmp').dialog('option','modal',false);
	HRMCommon.openDialog('dlgSelectEmp');
}

function empAdd(){
	var selectedName = empSelector_choseEmpNameStr();
	var selectedId = empSelector_choseEmpIdStr();
	selectedId = selectedId.replace(new RegExp(";","gm"),",");
	$("#empName").val(selectedName);
	$("#empId").val(selectedId);
	HRMCommon.closeDialog('dlgSelectEmp');
}

HRMCommon.initDialog('dlgAddEmpBenefit');
HRMCommon.initDialog('dlgChooseManager');
HRMCommon.initDialog('dlgModifyEmpBenefit');
HRMCommon.initDialog('dlgSelectEmp',560);
</script>
	<%@ include file="../profile/search_emp_div.jsp"%>
</body>